***************************
** Ethnic Party Success **
***************************

** set for hierarchical models; define clusters
xtset cowcode 

**********************************
** Table 1: Hypotheses Testing **

* M1a state nationalism 
xtlogit EthnicParty symbolicNSindex i.year, intpoints(50)
estimates store M1a

* M1b 
xtlogit EthnicParty symbolicNSindex GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store M1b

* M2a radical right success
xtlogit EthnicParty RRPerVoteLagged i.year, intpoints(50)
estimates store M2a

* M2b 
xtlogit EthnicParty RRPerVoteLagged GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store M2b

* M3a minority distinctiveness
xtlogit EthnicParty indexdistinctiveness i.year, intpoints(50)
estimates store M3a

* M3b 
xtlogit EthnicParty indexdistinctiveness GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store M3b

* M4a collective ethnic rights 
xtlogit EthnicParty EthnicRights i.year, intpoints(50)
estimates store M4a

* M4b 
xtlogit EthnicParty EthnicRights GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store M4b

* M5a district magnitude 
xtlogit EthnicParty MeanDM i.year, intpoints(50)
estimates store M5a

* M5b 
xtlogit EthnicParty MeanDM GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store M5b

estimates stats M1a M1b M2a M2b M3a M3b M4a M4b M5a M5b 


** Table 2: Competing Hypotheses; Full Models

* M1
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM i.year, intpoints(50)
estimates store M1

* M2
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store M2

estimates stats M1 M2 

*******************
** creating figure 1 requires to split sample (delete part of the dataset); based on the value of CommLegacy 
** for Western Europe: drop if CommLegacy==1
** for Eastern Europe: drop if CommLegacy==0
** then one runs full model according to specification M2, and same the coefplot

* WE
** this is M2 in Table E6 (appendix)
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM GroupEstimate v2x_polyarchy i.year, intpoints(50)
estimates store we
coefplot we, keep(symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM) xlin(0) grid(none) levels(95) ciopts(lwidth(*1 *3))
estimates stats we

* EE
** this is M4 in Table E6 (appendix)
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM GroupEstimate v2x_polyarchy i.year, intpoints(50)
estimates store ee
coefplot ee, keep(symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM) xlin(0) grid(none) levels(95) ciopts(lwidth(*1 *3))
estimates stats ee


******************
******************
** APPENDICES **

** Table E1: Controlling for the Presence of Ethnic Discrimination
* M1
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM EPRdiscriminated i.year, intpoints(50)
estimates store epr1

* M2
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM GroupEstimate v2x_polyarchy CommLegacy EPRdiscriminated i.year, intpoints(50)
estimates store epr2

estimates stats epr1 epr2

** Table E2: Accounting for Strength of Collective Ethnic Rights
* M1
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM i.year, intpoints(50)
estimates store cerd1

* M2
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store cerd2

estimates stats cerd1 cerd2

** Table E3: Results Excluding German (PL) and Roma (RO) Minorities Benefiting from Ethnic Quotas
** for models 1 and 2, we need to drop observations for German minority in Poland:
//this is only minority reported in the dataset so use: drop if cowcode==290
** for models 3 and 4, we also need to delete observations for Roma minority in Romania
//this must be done manually (to leave data on Hungarian minority in Romania)

** without Germans (PL)
* M1
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM i.year, intpoints(50)
estimates store noGera
* M2
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store noGerb

estimates stats noGera noGerb

** without Roma (RO) and Germans (PL)
* M3
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM i.year, intpoints(50)
estimates store noGerRoa
* M4
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store noGerRob

estimates stats noGerRoa noGerRob

** Table E4: Focus on Territorial Autonomy of Minorities
* M1
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicDevolution MeanDM i.year, intpoints(50)
estimates store dev1

* M2
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicDevolution MeanDM GroupEstimate v2x_polyarchy CommLegacy i.year, intpoints(50)
estimates store dev2

estimates stats dev1 dev2

** Table E5: Accounting for Legacy of Domination 
* M1
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM LegacyDom i.year, intpoints(50)
estimates store leg1

* M2
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM GroupEstimate v2x_polyarchy CommLegacy LegacyDom i.year, intpoints(50)
estimates store leg2

estimates stats leg1 leg2

** Table E6: Comparing Western and Eastern Europe
//one needs to drop a part of the sample based on the value of CommLegacy //
** for Western Europe: drop if CommLegacy==1
** for Eastern Europe: drop if CommLegacy==0

* WE
** M1 
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM i.year, intpoints(50)
estimates store wea

** M2 (also used in Figure 1; repeated above)
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM GroupEstimate v2x_polyarchy i.year, intpoints(50)
estimates store we

estimates stats wea we

* EE
** M3
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM i.year, intpoints(50)
estimates store eea

** M4 (also used in Figure 1; repeated above)
xtlogit EthnicParty symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRightsDegree MeanDM GroupEstimate v2x_polyarchy i.year, intpoints(50)
estimates store ee

estimates stats eea ee

** Table E7: Inclusion of Interaction Term between Former Communist Countries and Symbolic Nation State Index

xtlogit EthnicParty i.symbolicNSindex RRPerVoteLagged indexdistinctiveness EthnicRights MeanDM GroupEstimate v2x_polyarchy i.CommLegacy i.symbolicNSindex#i.CommLegacy i.year, intpoints(50)
estimates store it1

estimates stats it1 
